# @Time : 2021/2/15 11:56
# @Author : Li Kunlun
# @Description :
import numpy as np

#
v1 = dict(DNA=5 * np.random.rand(1, 1).repeat(2, axis=0),  # initialize the pop DNA values
          mut_strength=np.random.rand(2, 1))  # initialize the pop mutation strength values
# {'DNA': array([[3.10231811],
#        [3.10231811]]), 'mut_strength': array([[0.41897856],
#        [0.64807432]])}
print(v1)




print("------------------------")
# {'DNA': array([[9.90263869e+067],
#        [8.01304531e+262],
#        [2.60799828e-310],
#        [1.11259601e-306]])}
kids = {'DNA': np.empty((4, 1))}
print(kids)

print("------------------------")
players = ['charles', 'martina', 'michael', 'florence', 'eli']
print(players[:])

print("---------np.random.randn-----------")
# [-0.41021399  0.8743921  -0.4064391  -2.44508712]
print(np.random.randn(4))

print("---------np.clip-----------")
# 一维矩阵
x = np.arange(12)
print(np.clip(x, 3, 8))
# 多维矩阵
y = np.arange(12).reshape(3, 4)
print(np.clip(y, 3, 8))
# list列表
DNA_BOUND = [4, 8]
# [[4 4 4 4]
#  [4 5 6 7]
#  [8 8 8 8]]
print(np.clip(y, *DNA_BOUND))

print("--------v3和v3[:]测试------------")
v3 = np.array([1, -2, 3])
# v3 = np.maximum(v3 + 1, 0)
# [2 0 4]
# print(v3)
v3[:] = np.maximum(v3 + 1, 0)
# [2 0 4]
print(v3)

print("---------------")
v4 = np.array([1, 2, 3, 4])
# [3 4]
print(v4[-2:])

